import { JsonProperty, Serializable } from '@/plugins/reflect-metadata';

@Serializable()
export default class ChangePassword {
  @JsonProperty('oldPassword')
    oldPassword: string = '';

  @JsonProperty('confirmPassword')
    confirmPassword: string = '';

  @JsonProperty('newPassword')
    newPassword: string = '';

  get passwordsMatch(): boolean {
    return this.newPassword !== this.confirmPassword;
  }

  get isValid(): boolean {
    return Boolean(this.oldPassword && this.newPassword && this.confirmPassword);
  }

  get newIsSameToOld(): boolean {
    return this.oldPassword === this.newPassword;
  }

  get query() {
    return {
      oldPassword: this.oldPassword,
      newPassword: this.newPassword,
    };
  }
}
